package game.core
{
	public class ConfigManager
	{
		public function ConfigManager()
		{
		}
		
		private static var _configXml:XML;
		private static var _serverHost:String;
		private static var _serverPort:uint;
		private static var _modules:Array;
		
		public static function setData(data:XML):void
		{
			_configXml = data;
			_serverHost = _configXml.config.host;
			_serverPort = parseInt(_configXml.config.port);
			
			_modules = [];
			for each (var item:XML in _configXml.files.item)
			{
				var module:Object = {};
				module.id = String(item.@id);
				module.name = String(item.@name);
				module.url = String(item.@url) + "?v=" + Math.random();
				module.version = String(item.@version);
				
				_modules.push(module);
			}
		}
		
		public static function getModules():Array
		{
			return _modules;
		}
		
		public static function get serverHost():String
		{
			return _serverHost;
		}
		
		public static function get serverPort():uint
		{
			return _serverPort;
		}
	}
}